#!/usr/bin/env python
# coding=utf-8


import platform

_supported_dists = (
    'SuSE', 'debian', 'fedora', 'redhat', 'centos',
    'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo',
    'UnitedLinux', 'turbolinux', 'neokylin', 'ubuntu')  # linux系统的列表


class OSINFO:
    def __init__(self):
        pass

    @staticmethod
    def get_system_type():
        """获取操作系统类型 :"""
        return platform.system()

    @staticmethod
    def get_platform():
        """"获取操作内核版本信息"""
        return platform.platform()

    @staticmethod
    def get_dist():
        """获取操作系统名称"""
        return platform.dist()

    @staticmethod
    def get_release():
        """"获取操作系统内核版本号"""
        return platform.release()

    @staticmethod
    def get_linux_distribution():
        """linux获取操作系统发行版本名称"""
        return platform.linux_distribution(supported_dists=_supported_dists)

    @staticmethod
    def get_linux_system_name():
        """linux获取操作系统名称"""
        return platform.linux_distribution(supported_dists=_supported_dists)[0]

    @staticmethod
    def get_linux_system_release():
        """linux获取操作系统版本号"""
        return platform.linux_distribution(supported_dists=_supported_dists)[1]

    @staticmethod
    def get_win32_ver():
        """win 获取操作系统发行版本名称"""
        return platform.win32_ver()

    @staticmethod
    def get_version():
        """操作系统发行版本信息"""
        return platform.version()

    @staticmethod
    def get_architecture():
        """获取操作系统的位数"""
        return platform.architecture()

    @staticmethod
    def get_architecture_bit():
        """获取操作系统的位数"""
        return platform.architecture()[0]

    @staticmethod
    def get_cpu_type():
        """计算机处理器类型"""
        return platform.machine()

    @staticmethod
    def get_processor():
        """计算机处理器信息"""
        return platform.processor()

    @staticmethod
    def get_node():
        """计算机的网络名称"""
        return platform.node()

    @staticmethod
    def get_uname():
        """汇总信息"""
        return platform.uname()

    def get_all_info(self):
        """打印os的部分信息"""
        systype = platform.system()

        os_systemtype = "操作系统类型 : %s\n" % str(self.get_system_type())
        os_platform = "操作系统名称及内核版本号 : %s\n" % str(self.get_platform())
        # os_dist = "操作系统名称 : %s\n" % str(self.get_dist())
        os_release = "操作系统内核版本号：%s\n" % str(self.get_release())

        if systype == "Windows":
            os_distribution = "操作系统发行版本名称 : %s\n" % str(self.get_win32_ver())
        elif systype == "Linux":
            os_distribution = "操作系统发行版本名称 : %s\n" % str(
                self.get_linux_distribution())
        else:
            # os_distribution = "操作系统发行版本名称 : (暂不支持该系统)\n"
            os_distribution = ""

        os_version = "操作系统发行版本信息 : %s\n" % str(self.get_version())
        os_architecture = "操作系统的位数 : %s\n" % str(self.get_architecture())
        os_node = "计算机网络名称 : %s\n" % str(self.get_node())
        os_uname = "汇总信息 : %s\n" % str(self.get_uname())

        info = "".join([os_systemtype,
                        os_platform,
                        os_release,
                        os_distribution,
                        os_version,
                        os_architecture,
                        os_node,
                        os_uname])
        return info


if __name__ == '__main__':
    info = OSINFO()
    f = info.get_all_info()
    print(f)
